package com.ebelter.bodyfatscale.ui.pager.register;

import android.content.Context;
import android.icu.util.TimeUnit;
import android.view.ViewTreeObserver;

import com.ebelter.bodyfatscale.R;
import com.ebelter.bodyfatscale.model.Birthday;
import com.ebelter.bodyfatscale.ui.view.BirthdayView;
import com.ebelter.bodyfatscale.util.ScaleBaseUtils;

import java.util.Calendar;


/**
 * 生日页
 */

public class BirthdayPager extends BasePager {

    private BirthdayView bdvBirthday;

    public BirthdayPager(Context context) {
        super(context);
    }

    @Override
    protected int loadLayoutById() {
        return R.layout.pager_birthday;
    }

    @Override
    public void initViews() {

        final int curMonth = Calendar.getInstance().get(Calendar.MONTH) + 1;
        final int curDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);

        bdvBirthday = mRootView.findViewById(R.id.bdv_birthday_pager);

        bdvBirthday.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                bdvBirthday.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                bdvBirthday.setCurrentDate(1988, curMonth,curDay);
            }
        });
    }

//    @Override
//    public void initData(Object data) {
//        bdvBirthday.setCurrentDate(1988, 1, 1);
//    }


    public Birthday getBirthday() {
        return bdvBirthday.getBirthday();
    }
}
